package cn.ac.cintcm.synonymous;

import java.util.HashSet;
import java.util.Set;

public class TableParam {
    private short tableId;
    private char compareType;
    private Set<Short> categories;
    
    @Override
    public int hashCode() {
        final int PRIME = 31;
        int result = 1;
        result = PRIME * result + tableId;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final TableParam other = (TableParam) obj;
        if (tableId != other.tableId)
            return false;
        return true;
    }

    public TableParam() {
        categories = new HashSet<Short>();
    }
    
    public TableParam(short tableId) {
        this.tableId = tableId;
        categories = new HashSet<Short>();
    }
    
    public Set<Short> getCategories() {
        return categories;
    }
    
    public boolean addCategory(short category) {
        boolean added = false;
        if (!categories.contains(category)) {
            categories.add(category);
            added = true;
        }
        return added;
    }
    
    public boolean removeCategory(short category) {
       
       return categories.remove(category);
    }
    
    public char getCompareType() {
        return compareType;
    }
    public void setCompareType(char compareType) {
        this.compareType = compareType;
    }
    public short getTableId() {
        return tableId;
    }
    public void setTableId(short tableId) {
        this.tableId = tableId;
    }


}
